
//选项卡及li的点击切换
var oNav=getByClass("order-nav")[0];
var aLi=oNav.getElementsByTagName("li");
var aOrderbd=getByClass("order-bd");

for(var i=0;i<aLi.length;i++){
    aLi[i].index=i;
    aLi[i].onclick=function(){
        for(var k=0;k<aLi.length;k++){//先清空所有的样式
            aLi[k].className ='';
            aOrderbd[k].style.display ='none';
        }
        //给当前的按钮和div添加样式
        this.className ='on';
        aOrderbd[this.index].style.display ='block';
    };
}

//删除订单
var aBtn=getByClass("dele");
var aOrder=getByClass("aorder");
for (var i=0;i<aBtn.length;i++){
    aBtn[i].index=i;
    aBtn[i].onclick=function(){
            var r=confirm("您确定要删除此订单吗？");
            if (r==true) {
                aOrder[this.index].style.display="none";
            }
    }
}

function getByClass(sClassName) {
    var aEls = document.getElementsByTagName("*");
    var arr = [];
    for (var i = 0; i < aEls.length; i++) {
        var aClassName = aEls[i].className.split(' ');
        for (var j = 0; j < aClassName.length; j++) {
            if (aClassName[j] == sClassName) {
                arr.push(aEls[i]); //将含有要找的className的元素存在数组中
            }
        }
    }
    return arr;
}